//
//  XKShaderLayer.cpp
//  IMFans
//
//  Created by Joueu on 14-12-2.
//
//

#include "ShaderLayer.h"

bool ShaderLayer::init()
{
    if (!Layer::init()) {
        return false;
    }
    Size visibleSize = Director::getInstance() -> getVisibleSize();
    auto color = LayerColor::create(Color4B(0, 0, 0, 200), visibleSize.width, visibleSize.height);
    this -> addChild(color);

    auto item = MenuItemImage::create();
    item -> setContentSize(visibleSize);
    item -> setCallback([&](Ref *pSender){
        //背景图点击时候执行
        if (clickBGBlock != NULL) {
            this -> clickBGBlock();
        }
    });
    
    auto menu = Menu::create(item, NULL);
    this -> addChild(menu);
    return true;
}

void ShaderLayer::setClickBgBlock(std::function<void ()> block)
{
    clickBGBlock = block;
}